package ypmits.components.listbox.button {
	import ypmits.components.buttons.BasicButton;

	import flash.display.BlendMode;
	import flash.display.Sprite;
	import flash.events.MouseEvent;

	/**
	 * @author Dave Lenz
	 */
	public class ListBoxButton extends Sprite {

		private var data : ListBoxButtonData;
		private var button : BasicButton;

		
		public function ListBoxButton( data : ListBoxButtonData ) {
			this.data = data;
			
			button = new BasicButton( );
			button.alpha = .5;
			button.width = 120;
			button.height = 22;
			button.text = data.label;
			button.addEventListener( MouseEvent.CLICK, buttonClickHandler );
			addChild( button );
			
			enable();

			blendMode = BlendMode.LAYER;
		}
		
		private function buttonClickHandler( e : MouseEvent ) : void {
			data.handlerFunction();
		}

		
		public function enable() : void {
			button.enable();
		}
		
		
		public function disable() : void {
			button.disable();
		}

		
		override public function set width( value : Number ) : void {
			button.width = value;
		}
	}
}
